import { Command, pcommand } from "../SAPI-Pro/Command/main";
import { intervalBus, itemBus, ScriptEventBus } from "../SAPI-Pro/Event";
import { getPlayerById } from "../SAPI-Pro/func";
import { musicCommandObject, musicForm, musicPlay, showlrc } from "./music";
const musicCommand = Command.fromObject(musicCommandObject);
pcommand.registerNative(
  new Command("musicplayer", "打开音乐播放器UI", false, (p) => musicForm(p, 0))
);
// pcommand.registerCommand(musicCommand);
intervalBus.subscribesec(musicPlay);
intervalBus.subscribetick(showlrc);
itemBus.bind("musicplayer:book", (player) => {
  musicForm(player, 0);
});
ScriptEventBus.bind("music:open", (t) => {
  const player = getPlayerById(t.message);
  if (player) {
    musicForm(player, 0);
  }
});
